<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/binge.css" />
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<!-- header -->
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <div class="header" style="margin-bottom: 0;">
        <div class="head-back">
            <a href="javascript:void(0);" tapmode onclick="comeBack()" class="back-btn"></a>
        </div>
        <div class="head-title">
            <h6>申请圈主</h6>
        </div>
        <!--<div class="head-action">-->
            <!--<a href="javascript:void(0);" tapmode onclick="commonUrl('follow_school')" class="action-btn"></a>-->
        <!--</div>-->
    </div>
</div>
<!-- header end -->
<div class="header-h" style="padding-top: 1.4rem;"></div>
<div class="reply-section">
    <div class="reply-textarea">
        <textarea name="" id="content" cols="30" rows="10" placeholder="Uni小提示：请描述您过往的相关经历和成为圈主后对本圈的展望…"></textarea>
    </div>
    <div class="upload-img">
        <div class="common-title">
            <h6>上传资料（选填）</h6>
        </div>
        <div class="activity-detail">
            <ul id="icons">
                <!--<li>
                    <img src="../../image/img-media01.png" alt="">
                    <div class="delete"></div>
                </li>-->
                <li class="choose-pic" id="choosePic" tapmode onclick="upload()">
                    <div class="pic-icon">照片</div>
                </li>
            </ul>
        </div>
    </div>
    <div class="common-fixed-bottom">
        <a href="javascript:void(0);" tapmode onclick="submitForm()" class="fixed-bottom">申请成为圈主</a>
    </div>
</div>


</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var circle_id = '';
    var icons = [];//上传的图片
    apiready = function() {

        setFixStatusBar(); //设置状态栏
        circle_id = api.pageParam.circle_id;

        keybackListener();

    }

    //提交信息
    function submitForm() {
        var icons_ids = icons.join(',');
        var param = {
            token: $api.getStorage('token'),
            circle_id: circle_id,
            content: $('#content').val(),
            icons: icons_ids,
        }
        if (!isDefine(param.content)){
            pop.notice('请输入申请内容');
            return;
        }
        /*if (!isDefine(param.icons)){
            pop.notice('请上传你的申请资料');
            return;
        }*/
        pop.loading();
        getAjax(Interface.set_circle_member, param, function (res) {
            pop.notice('申请成功，请等待审核');
            setTimeout(function () {
                comeBack()
            },1000)
            pop.close();
        },function (error) {
            pop.notice(error.msg);
            pop.close();
        })
    }


    //上传图片
    function upload() {
        uploadHeadPic(function (res) {
            $("#choosePic").before('<li data-id="' + res.icon + '"><img src="' + ajaxUrl + res.path + '" alt=""><div class="delete"></div></li>');
            icons.push(res.icon)
        })
        console.log(jsonChange(icons))
    }

    //删除图片
    $("#icons").on('click', '.delete', function () {
        var _this = $(this);
        var re_id = _this.parents('li').attr('data-id');
        _this.parents('li').remove();
        icons.splice($.inArray(re_id, icons), 1);
        console.log(jsonChange(icons))
    });






</script>
